package com.sharemarking.wa.platform.service.OrderCommonFactory;

import com.sharemarking.wa.platform.dto.orderCommon.OrderInfoDto;
import com.sharemarking.wa.platform.dto.orderCommon.OrderListDto;
import com.sharemarking.wa.platform.dto.orderCommon.TaskOrderListDto;
import com.sharemarking.wa.platform.mapper.OrderCommonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author dxy
 */
@Component
public class OrderCommonFactory implements OrderCommon {
    @Autowired
    ProductWaste productWaste;
    @Autowired
    OrderManagement orderManagement;
    @Autowired
    OrderDriver orderDriver;
    @Autowired
    OrderDispatch orderDispatch;
    @Autowired
    OrderCommonMapper orderCommonMapper;

    @Override
    public List<OrderListDto> getOrderList(Map params) {
        List<OrderListDto> orderList = null;
        Integer role = (Integer) params.get("role");
        switch (role) {
            case 0:
                orderList = productWaste.getOrderList(params);
                break;
            case 1:
                orderList = orderManagement.getOrderList(params);
                break;
            case 2:
                orderList = orderDriver.getOrderList(params);
                break;
            case 3:
                orderList = orderDispatch.getOrderList(params);
                break;
            case 4:
                orderList = orderDispatch.getOrderList(params);
                break;
        }

        return orderList;
    }


    @Override
    public OrderInfoDto getOrderInfo(Map params) {
        Integer role = (Integer) params.get("role");
        OrderInfoDto orderInfoDto = null;
        switch (role) {
            case 0:
                orderInfoDto = productWaste.getOrderInfo(params);
                break;
            case 1:
                orderInfoDto = orderManagement.getOrderInfo(params);
                break;
            case 2:
                orderInfoDto = orderDriver.getOrderInfo(params);
                break;
            case 3:
                orderInfoDto = orderDispatch.getOrderInfo(params);
                break;
            case 4:
                orderInfoDto = orderDispatch.getOrderInfo(params);
                break;
        }

        return orderInfoDto;
    }

    @Override
    public List<TaskOrderListDto> getTaskOrderList(Map params) {
        Integer role = (Integer) params.get("role");
        List<TaskOrderListDto> list = null;
        switch (role) {
            case 1:
                list = orderManagement.getTaskOrderList(params);
                break;
            case 2:
                list = orderDriver.getTaskOrderList(params);
                break;
            case 3:
                list = orderDispatch.getTaskOrderList(params);
                break;
        }
        return list;
    }

    @Override
    public OrderInfoDto getTaskOrderInfo(Map params) {
        Integer role = (Integer) params.get("role");
        OrderInfoDto orderInfoDto = null;
        switch (role) {
            case 1:
                orderInfoDto = orderManagement.getTaskOrderInfo(params);
                break;
            case 2:
                orderInfoDto = orderDriver.getTaskOrderInfo(params);
                break;
            case 3:
                orderInfoDto = orderDispatch.getTaskOrderInfo(params);
                break;
            case 4:
                orderInfoDto = orderDispatch.getTaskOrderInfo(params);
                break;
        }

        return orderInfoDto;
    }


}
